<template>
  <div class="page-top">
    <div class="title">
      <span>远程视频辅助收件系统</span>
      <span class="time">{{ nowTime }}</span>
      <span class="user" v-show="sysStore.userInfo?.display_name">欢迎您：{{sysStore.userInfo.display_name}}</span>
    </div>
    <div class="top-option" v-if="isElectron">
      <span @click="loginOut" class="iconfont">&#xe621;</span>
      <span @click="optionWin('minWin')" class="iconfont">&#xe650;</span>
      <span @click="optionWin('maxWin')" class="iconfont">&#xe692;</span>
      <span @click="optionWin('closeWin')" class="iconfont">&#xe62f;</span>
    </div>
     <div class="work-top" v-if="!isElectron">
      <div class="btn" @click="goBack">
        <svg class="icon" aria-hidden="true">
          <use :xlink:href="'#icon-back'"></use>
        </svg>
        <span class="text">返回</span>
      </div>
      <div class="btn" @click="openAgent">
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-wenda"></use>
        </svg>
        <span class="text">问答</span>
      </div>
      <div class="btn" @click="loginOut">
        <img class="btn-img" src="../assets/images/index/loginout.png">
        <span class="text">退出</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {useRouter} from "vue-router";
import {useSysStore} from "stores/sysStore";
import {loginOut,nowDate,userBehavior} from "src/utils/util";
import {ref} from "vue";

const nowTime = ref()
nowTime.value = nowDate()

let sysStore = useSysStore();
let router = useRouter();
let isElectron = ref(window.ipcChannel)
const optionWin = (active:string) => {
  (ipcChannel[active])();
}

// 返回
const goBack = ()=>{
router.go(-1)
}

// 问答
const openAgent = () => {
  userBehavior({ operation_type_id: 'view_agent' }) //用户行为统计
  window.open('https://deyang.flopsai.cn')
}
</script>

<style scoped lang="scss">
.page-top {
  width: 100%;
  height: 60px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;

  .title {
    -webkit-app-region: drag;
    flex: 1;
    display: flex;
    align-items: center;
    color: #fff;
    .time{
      font-weight: 400;
      @media (max-width: 1024px) {
        display: none;
      }
    }
    .user{
      font-weight: 300;
      color: #fff;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      margin: auto;
      line-height: 60px;
      width: 300px;
      text-align: center;
    }
    img {
      width: 30px;
      height: 30px;
    }

    span {
      padding-left: 15px;
      font-size: 16px;
      font-weight: bold;
      letter-spacing: 3px;
    }
  }

  .top-option {
    span {
      color: #fff;
      margin-left: 20px;
      cursor: pointer;
      scale: 1.0;
      transition: 0.2s all ease-in-out;
    }

    span:hover {
      scale: 1.2;
      transition: 0.2s all ease-in-out;
    }
  }
}
.work-top {
    position: fixed;
    right: 10px;
    top: 0;
    height: 60px;
    line-height: 60px;
    padding: 0 10px;
    display: flex;
    justify-content: end;
    align-items: center;

    .line-up {
      font-size: 20px;
      font-weight: 500;
      color: #8B2CF3;
    }

    .btn {
      position: relative;
      width: 35px;
      height: 35px;
      background-image: linear-gradient(-225deg, #679EF1 0%, #B587CF 48%, #9781EE 100%);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border-radius: 10px;
      cursor: pointer;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      color: white !important;
      margin-left: 20px;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 8px 32px rgba(68, 129, 235, 0.1);
      overflow: hidden;

      .btn-img {
        width: 22px;
        height: 22px;
      }

      &:hover {
        transform: translateY(-2px);
        background-image: linear-gradient(-225deg, #679EF1 0%, #B587CF 48%, #9781EE 100%);
        box-shadow: 0 12px 40px rgba(68, 129, 235, 0.2);

        .icon {
          transform: translateY(-8px) scale(0.8);
        }
        .btn-img {
          transform: translateY(-6px) scale(0.7);
        }

        .text {
          opacity: 1;
          transform: translateY(0);
        }
      }

      .icon,.btn-img {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        font-size: 15px;
      }

      .text {
        position: absolute;
        bottom: 3px;
        font-size: 10px;
        line-height: 12px;
        font-weight: 500;
        white-space: nowrap;
        opacity: 0;
        transform: translateY(10px);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
      }
    }
  }
</style>
